var spans = document.querySelectorAll('span')
console.log(spans);

setInterval(fn, 1000)

fn()

function fn() {

    // 获取到今晚9点的时间戳
    var date = +new Date('2024-12-9 21:0:0')
    // console.log(date)

    // 获取现在的时间戳
    var now = +new Date()
    // console.log(now)

    // 求差 - 计算出现在到过年还有多少时间
    var diff = date - now
    // console.log(diff)

    // 求天
    // var day = parseInt(diff / 1000 / 60 / 60 / 24)
    // console.log(day)
    // 求小时
    var hour = parseInt(diff / 1000 / 60 / 60) % 24
    // console.log(hour)
    // 求分钟
    var minute = parseInt(diff / 1000 / 60) % 60
    // console.log(minute)
    // 求秒
    var second = parseInt(diff / 1000) % 60
    // console.log(second)

    spans[0].innerText = hour
    spans[1].innerText = minute
    spans[2].innerText = second
}